package com.crm.service.impl.userForumManager;

import com.crm.dao.mapper.customMapper.userForumCustomManager.UserForumReplyCustomMapper;
import com.crm.dao.mapper.userForumManager.UserForumReplyMapper;
import com.crm.model.entity.userForumManager.UserForumReply;
import com.crm.model.vo.userForumManager.UserForumReplyVO;
import com.crm.service.userForumManager.UserForumReplyDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import sun.dc.pr.PRError;

import java.util.List;

/**
 * @Author:chaifuyou
 * @Date: 2021/5/24 9:45
 */
@Service
public class UserForumReplyDbServiceImpl implements UserForumReplyDbService {

    @Autowired
    private UserForumReplyMapper userForumReplyMapper;

    @Autowired
    private UserForumReplyCustomMapper userForumReplyCustomMapper;

    /**
     * 添加评论
     * @param userForumReply
     */
    @Override
    public boolean addForumReply(UserForumReply userForumReply) {
        return userForumReplyMapper.insertSelective(userForumReply) > 0;
    }

    /**
     * 查看评论
     * @param userForumId
     * @param order
     * @return
     */
    @Override
    public List<UserForumReplyVO> selectForumReply(String userForumId, String order) {
        return userForumReplyCustomMapper.selectForumReply(userForumId,order);
    }

    /**
     * 查看子评论
     * @param userForumReplyId
     * @param order
     * @return
     */
    @Override
    public List<UserForumReplyVO> selectForumSonReply(String userForumReplyId, String order) {
        return userForumReplyCustomMapper.selectForumSonReply(userForumReplyId,order);
    }

    /**
     * 加阅读次数
     * @param userForumId
     */
    @Override
    public void addReadNumberByUserForumId(String userForumId) {
        userForumReplyCustomMapper.addReadNumberByUserForumId(userForumId);
    }

    /**
     * 通过评论级别和pid查询评论
     * @param level
     * @param order
     * @param limit
     * @param pid
     * @return
     */
    @Override
    public List<UserForumReplyVO> selectForumReplyByLevel(Integer level, String order, Integer limit, String pid,String userForumId) {
        return userForumReplyCustomMapper.selectForumReplyByLevel(level,order,limit,pid,userForumId);
    }

    /**
     * 通过评论级别和pid查询评论
     * @param level
     * @param order
     * @param limit
     * @param pid
     * @param userForumId
     * @return
     */
    @Override
    public List<UserForumReplyVO> selectForumReplyByPid(Integer level, String order, Integer limit, String pid, String userForumId) {
        return userForumReplyCustomMapper.selectForumReplyByPid(level,order,limit,pid,userForumId);
    }

    /**
     * 根据评论id查询
     * @param userForumReplyId
     * @return
     */
    @Override
    public UserForumReplyVO selectForumReplyById(String userForumReplyId) {
        return userForumReplyCustomMapper.selectForumReplyById(userForumReplyId);
    }

    /**
     * 删除评论
     * @param userForumReplyId
     * @return
     */
    @Override
    public boolean delForumReply(String userForumReplyId) {
        return userForumReplyCustomMapper.delForumReply(userForumReplyId) > 0;
    }
}
